package controller;

import gui.TokenGetter;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import client.TokenClient;

public class GenNewToken implements ActionListener {

	private TokenClient client;
	private TokenGetter gui;

	public GenNewToken(TokenGetter gui, TokenClient client) {
		this.client = client;
		this.gui = gui;
	}

	@Override
	public void actionPerformed(ActionEvent e) {
		String username = (String) gui.getCb_user().getSelectedItem();
		int pin = Integer.parseInt(gui.getTxt_pin().getText());

		client.setUsername(username);
		client.setPin(pin);
		
		gui.getTxt_token().setText(client.getToken() + "");
		gui.getPb_countDown().setValue(60);
	}

}
